﻿@model IEnumerable<MvcApplication2.Controllers.ExerciseTestViewModel>
@{
    ViewBag.Title = "Exercise in testing";
}
<h2>@ViewBag.Title</h2>
<p>
    @Html.ActionLink("Sort By", "Index", null, new { @class = "btn btn-mini" })
</p>
<table class="table table-striped">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.Exercise.Owner)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Tester)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Exercise)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Reward)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.ExerciseStatus)
        </th>
        <th>
        </th>
        <th>
        </th>
    </tr>
    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Exercise.Owner.DisplayName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Tester.DisplayName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Exercise.Title)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Reward)
            </td>
            <td>
                <span class="label @item.GetLabelClass">@item.GetLocalizedStatusMessage</span>
            </td>
            <td>
                @{ 
        if (item.ShowAcceptButton)
        {
                    @Html.ActionLink("Accept", "AcceptTestExercise", new { id = item.UserMessageId }, new { @class = "btn btn-mini btn-success" })
                    @Html.ActionLink("Tratta", "AskDifferentPrice", new { id = item.UserMessageId }, new { @class = "btn btn-mini" })
                    @Html.ActionLink("Rifiuta", "TrashProposal", new { id = item.UserMessageId }, new { @class = "btn btn-mini btn-warning" })
        }
        //if (item.ShowVoteUser)
        {
                    @Html.ActionLink("Vote User", "VoteUser", new { id = item.UserMessageId, dev = item.OwnerId, tester = item.TesterId }, new { @class = "btn btn-success" })
        }
                }
                @Html.ActionLink("Details", "Details", new { id = item.UserMessageId }, new { @class = "btn btn-mini" })
                @if (!item.ShowAcceptButton)
                {
                    @Html.ActionLink("Delete", "DeleteWork", new { id = item.UserMessageId }, new { @class = "btn btn-mini btn-warning" })
                }
            </td>
            <td>
                @if (item.ShowPayButton)
                {
                    <form class="form-inline" action="https://www.sandbox.paypal.com/cgi-bin/webscr"
                    method="post">
                    <input type="hidden" name="cmd" value="_xclick" />
                    <input type="hidden" name="business" value="@item.Tester.PayPalMail" />
                    <input type="hidden" name="item_name" value="@item.Tester.DisplayName" />
                    <input type="hidden" name="shopping_url" value="@Request.Url.AbsoluteUri">
                    <input type="hidden" name="no_shipping" value="1">
                    <input type="hidden" name="return" value="http://@Request.Url.Host:@Request.Url.Port/PayPal/ReturnSuccess">
                    <input type="hidden" name="notify_url" value="http://@Request.Url.Host:@Request.Url.Port/PayPal/ReturnSuccess">
                    <input type="hidden" name="rm" value="2">
                    <input type="hidden" name="cancel_return" value="http://@Request.Url.Host:@Request.Url.Port/PayPal/CancelledPayment" />
                    <input type="hidden" name="amount" value="@item.Reward" />
                    <input type="submit" class="btn btn-mini btn-success" value="Pay Tester" />
                    </form>
                }
            </td>
        </tr>
    }
</table>
